package dataservice.financialdataservice.driver;

import java.util.ArrayList;

import po.CashRecordLineItem;
import po.CashRecordList;
import po.CashRecordPO;
import po.UserPO;
import utility.TimePeriod;
import data.financialdata.stub.CashReportDataServiceSerializableImplStub;
import dataservice.financialdataservice.CashRecordDataService;

public class CashRecordDataService_Driver {
	public void drive(CashRecordDataService cashRecordService){
		CashRecordList list = new CashRecordList();
		list.add(new CashRecordLineItem("name", 12312, "comment"));
		CashRecordPO po = new CashRecordPO("accountId",list,"userId");
		boolean result = cashRecordService.addCashRecord(po);
		if(result){
			System.out.println("add CashRecord pass");
		}else{
			System.out.println("add CashRecord failed");
		}
		
		CashRecordPO findResult = cashRecordService.find("XJFYD-yyyyMMdd-xxxxx");
		if(findResult != null){
			System.out.println("find cashrecord successfully");
		}else{
			System.out.println("find cashrecord failed");
		}
		ArrayList<CashRecordPO> cashRecordList = null;
		try {
			cashRecordList = cashRecordService.mutipleConditionSearch(new TimePeriod("2014-02-12","2014-03-13"), new UserPO("Nero","007","sad23"));
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		if(!cashRecordList.isEmpty()){
			System.out.println("mutiple condition find cashrecord successfully");
		}else{

			System.out.println("mutiple condition find cashrecord failed");
		}
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		CashRecordDataService cashRecordService = new CashReportDataServiceSerializableImplStub();
		CashRecordDataService_Driver driver = new CashRecordDataService_Driver();
		driver.drive(cashRecordService);
	}

}
